package logic

import (
	"context"
	"youngwind-first/demo/internal/svc"
	"youngwind-first/demo/internal/types"
	"youngwind-first/demo/model/gorm_model"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserInfoLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserInfoLogic {
	return &UserInfoLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UserInfoLogic) UserInfo(user *types.User) (resp gorm_model.User, err error) {

	resp = gorm_model.User{}
	resultErr := l.svcCtx.DbEngin.Where("id = ?", user.Id).Find(&resp).Error
	if resultErr != nil {
		return resp, err
	}
	return
}
